/**
 * @author SilverBiology, LLC
 * @website http://code.google.com/p/gbif-spreadsheet-processor/
*/
MappingLayers = function(layername, zoom, data){

	switch(layername) {
		case 'GBIF All Occurences':
			var data = MappingForGBIFOccurances(zoom, data);
			return data;
			break;
		case 'Africa Colonial History':
			var data = data.FeatureInfoResponse.FIELDS;
			return data;
			break;
		case 'gbif:named_areas':
			var data = data.FeatureCollection.featureMember.named_areas;
			return data;
			break;
		case 'GBIF All Occurences':
			var data = [data.FeatureCollection.featureMember.cluster1];
			return data;
			break;	
		case 'GBIF Cluster10':
			var data = [data.FeatureCollection.featureMember.cluster10];
			return data;
			break;
		case 'GBIF Cluster1':
			var data = [data.FeatureCollection.featureMember.cluster1];
			return data;
			break;				
		case 'GBIF Cluster100':
			var data = [data.FeatureCollection.featureMember.cluster10];
			return data;
			break;	
		case 'GBIF Tax Occurrence':
			var data = MappingForGBIFTaxOccurances(zoom , data);
			return data;
			break;
		case 'GBIF Scratch Pad':
			var data = [data.FeatureCollection.featureMember.scratchpad];
			return data;
			break;										
	}
}

MappingForGBIFOccurances=function(zoom, data){
	if(zoom < 6) {
		return [data.FeatureCollection.featureMember.cluster1];
	} else if(zoom < 10) {
		return [data.FeatureCollection.featureMember.cluster10];
	} else if(zoom < 13) {
		return [data.FeatureCollection.featureMember.cluster100];
	} else if(zoom > 12) {
		return [data.FeatureCollection.featureMember.occurrence_full];
	}
}

MappingForGBIFTaxOccurances=function(zoom, data){
	if(zoom < 6) {
		return [data.FeatureCollection.featureMember.tax_cluster1];
	} else if(zoom < 10) {
		return [data.FeatureCollection.featureMember.tax_cluster10];
	} else if(zoom < 13) {
		return [data.FeatureCollection.featureMember.tax_cluster100];
	} else if(zoom > 12) {
		return [data.FeatureCollection.featureMember.occurrence_full];
	}
}